package com.wolfden.drugserver;

import java.sql.DriverManager;

import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;

import com.wolfden.drugserver.banking.MoneyMap;
import com.wolfden.drugserver.commands.AdminCommandManager;
import com.wolfden.drugserver.commands.BankCommandManager;
import com.wolfden.drugserver.commands.SpawnCommandManager;
import com.wolfden.drugserver.commands.WarpCommandManager;
import com.wolfden.drugserver.spawning.SpawnMap;
import com.wolfden.drugserver.warping.WarpMap;

public class DrugPlugin extends JavaPlugin {

	Plugin plugin;

	public void onEnable() {

		plugin = this;

		getLogger().info("DrugPlugin enabled!");

		try {
			Class.forName("org.sqlite.JDBC");
			Constants.connection = DriverManager
					.getConnection("jdbc:sqlite:accounts.db");
		} catch (Exception e) {
		}

		Constants.moneyMap = new MoneyMap(this);
		Constants.warpMap = new WarpMap(this);
		Constants.spawnMap = new SpawnMap(this);

		new EventManager(this);

		BankCommandManager bankCommandManager = new BankCommandManager();
		getCommand("balance").setExecutor(bankCommandManager);
		getCommand("deposit").setExecutor(bankCommandManager);
		getCommand("pay").setExecutor(bankCommandManager);
		getCommand("transfer").setExecutor(bankCommandManager);
		getCommand("userBalance").setExecutor(bankCommandManager);
		getCommand("withdraw").setExecutor(bankCommandManager);

		AdminCommandManager adminCommandManager = new AdminCommandManager(this);
		getCommand("comehere").setExecutor(adminCommandManager);
		getCommand("goto").setExecutor(adminCommandManager);
		getCommand("kick").setExecutor(adminCommandManager);
		getCommand("killall").setExecutor(adminCommandManager);
		getCommand("makeadmin").setExecutor(adminCommandManager);
		getCommand("teleall").setExecutor(adminCommandManager);

		WarpCommandManager warpCommandManager = new WarpCommandManager();
		getCommand("listwarps").setExecutor(warpCommandManager);
		getCommand("movewarp").setExecutor(warpCommandManager);
		getCommand("removewarp").setExecutor(warpCommandManager);
		getCommand("renamewarp").setExecutor(warpCommandManager);
		getCommand("setwarp").setExecutor(warpCommandManager);
		getCommand("warp").setExecutor(warpCommandManager);

		SpawnCommandManager spawnCommandManager = new SpawnCommandManager();
		getCommand("setspawn").setExecutor(spawnCommandManager);
		getCommand("spawn").setExecutor(spawnCommandManager);
	}

	public void onDisable() {
		getLogger().info("DrugPlugin disabled...");
	}
}
